<?php
    /**
     * Created by PhpStorm.
     * User: zgh
     * Date: 2021-07-30
     * Time: 16:44
     */

    namespace app\api\controller;

    use app\api\service\LoginService;
    use app\common\Annotation\ApiControllerAnnotation;
    use hg\apidoc\annotation as Apidoc;

    use app\common\controller\ApiController;
    use think\facade\Request;

    /**
     * @ApiControllerAnnotation(auth=0)
     * @Apidoc\Title("注册登陆")
     * @Apidoc\Group("base")
     * Class LoginController
     * @package app\api\controller
     */
    class LoginController extends ApiController
    {

        /**
         * @Apidoc\Title("发送验证码")
         * @Apidoc\Url("login/send_sms")
         * @Apidoc\Param("mobile", type="string",require=true, desc="手机号" )
         */
        public function send_sms()
        {
            $res = LoginService::sendSms(Request::param());
            if ($res) {
                return success_json_response("发送成功");
            } else {
                return json_response("发送失败");
            }
        }


        /**
         * @Apidoc\Title("登陆")
         * @Apidoc\Url("login/do_login")
         * @Apidoc\Param("login_type", type="string",require=true, desc="登陆方式" )
         * @Apidoc\Param("mobile", type="string",require=true, desc="手机号" )
         * @Apidoc\Param("verify_code", type="string",require=false, desc="验证码 login_type=1短信登陆需要" )
         * @Apidoc\Param("password", type="string",require=false, desc="密码 login_type=2账号密码登陆需要" )
         */
        public function do_login()
        {
            $res = LoginService::doLogin(Request::param());
            if ($res) {
                return success_json_response("登陆成功",$res);
            } else {
                return json_response("登陆失败");
            }
        }


        public function third_do_login(){
            $res = LoginService::doLogin(Request::param());
            if ($res) {
                return success_json_response("登陆成功",$res);
            } else {
                return json_response("登陆失败");
            }
        }


    }